I love the smell of UnrealEd crashing in the morning. – tarquin

Legacy:Animation Replication

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search

This page is about animations in UT2003.

After running into many problems with animations online, and after discovering many more have these problems, I decided to write this little how to/tut so new people can figure it out a bit more easy. I hope ;)

Basic Animation info[edit]

There are many ways to play animations, I guess most used are PlayAnim and LoopAnim. Animations are blended over different channels etc.

I am sure someone with great animation skills will someday make a animation tut.

Where it fails[edit]

It's important to know that the PlayAnim and related functions don't get replicated. This is where the real trouble starts. So you have yourself a good animation offline, now how do you make it work online?

The simple solution is well documented and goes like this:

//In your Pawn class
simulated event SetAnimAction(name NewAction)
{
    //This is the default animation replication method
    if (animaction != NewAction) {
       //This means that the animation played by the server is not the same as by the client
 
       //Do some checks here to see what animation should be played, and play it
    }
}

Now in this function you will be doing basicly the stuff done by the server also, for example:

//Somewhere in your code you do:
    PlayAnim('myanim',,,0);
    FreezeAnimAt(0,0);

So the myanim animation you need to be replicated. Now alter the SetAnimAction function to do this:

//In your Pawn class
simulated event SetAnimAction(name NewAction)
{
    //This is the default animation replication method
    if (animaction != NewAction) {
       //This means that the animation played by the server is not the same as by the client
       if (animaction == 'myanim') {
          PlayAnim(animaction,,,0);
          FreezeAnimAt(0,0);
    }
}

Well all nice and perfect so far, but it wont work online just yet.

First you need to set the animaction variable to make it replicate and let the client see that it needs to update. You do this by setting the AnimAction property of your pawn to the animation you told the server to play:

//Somewhere in your code you do:
    P.PlayAnim('myanim',,,0);
    P.FreezeAnimAt(0,0);
    P.SetAnimAction('myanim');

Need more control?[edit]

Well I did, some of my animations needed calculated properties to run smoothly with their environment. This is the hard part IMO. I decided to use boolean and integers that got replicated, then the pawn's Tick function would check the boolean and set the animation so it would use the proper calculated properties etc.

I am sure this part so far is clear, this isn't the hard part of online animations. ;)

Where the engine starts to interupt[edit]

Now when I tested my animation replication online I was shocked to see the pawn revert to default player animations at random moments. I spend then many hours trying to find the source of these animations. It turned out that a part of UT2003's engine does animation control already. These where overruling my animations all the time. A good way to solve this is by setting the Physics to PHYS_None, this stops the engine from updating your pawn.

Another part that overrules the animations is the AnimEnd function. You can simply subclass it and make it check for certain conditions where you don't want the animations to be overruled.

The End[edit]

So I hope this helps people to get their animations working online, its just a start. I might add more over time. Specially since I don't have it all working myself. ;)

Feel free to alter, fix and complete.

Related Topics[edit]


Category:Legacy Tutorial
Category:Legacy To Do – This needs merged into the grand topic of Replication. See Replication/Discussing